package com.xiaoshuidi.cloud.module.system.api.logger.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.Map;

/**
 * RPC 服务 - 操作日志创建 Request DTO
 */
@Schema(description = "RPC 服务 - 操作日志创建 Request DTO")
@Data
public class OperateLogCreateReqDTO {

    /**
     * 链路追踪编号
     */
    @Schema(description = "链路追踪编号", example = "89aca178-a370-411c-ae02-3f0d672be4ab")
    private String traceId;

    /**
     * 用户编号
     */
    @Schema(description = "用户编号", required = true, example = "1024")
    @NotNull(message = "用户编号不能为空")
    private Long userId;
    /**
     * 用户类型
     */
    @Schema(description = "用户类型", required = true, example = "1")
    @NotNull(message = "用户类型不能为空")
    private Integer userType;

    /**
     * 操作模块
     */
    @Schema(description = "操作模块", required = true, example = "订单")
    @NotEmpty(message = "操作模块不能为空")
    private String module;

    /**
     * 操作名
     */
    @Schema(description = "操作名", required = true, example = "创建订单")
    @NotEmpty(message = "操作名")
    private String name;

    /**
     * 操作分类,参见 SysOperateLogTypeEnum 枚举类
     */
    @Schema(description = "操作分类,参见 SysOperateLogTypeEnum 枚举类", required = true, example = "1")
    @NotNull(message = "操作分类不能为空")
    private Integer type;

    /**
     * 操作明细
     */
    @Schema(description = "操作明细", example = "修改编号为 1 的用户信息，将性别从男改成女，将姓名从合房改成源码。")
    private String content;

    /**
     * 拓展字段
     */
    @Schema(description = "拓展字段", example = "{'orderId': 1}")
    private Map<String, Object> exts;

    /**
     * 请求方法名
     */
    @Schema(description = "请求方法名", required = true, example = "GET")
    @NotEmpty(message = "请求方法名不能为空")
    private String requestMethod;

    /**
     * 请求地址
     */
    @Schema(description = "请求地址", required = true, example = "/xxx/yyy")
    @NotEmpty(message = "请求地址不能为空")
    private String requestUrl;

    /**
     * 用户 IP
     */
    @Schema(description = "用户 IP", required = true, example = "127.0.0.1")
    @NotEmpty(message = "用户 IP 不能为空")
    private String userIp;

    /**
     * 浏览器 UserAgent
     */
    @Schema(description = "浏览器 UserAgent", required = true, example = "Mozilla/5.0")
    @NotEmpty(message = "浏览器 UserAgent 不能为空")
    private String userAgent;

    /**
     * Java 方法名
     */
    @Schema(description = "Java 方法名", required = true, example = "com.xiaoshuidi.cloud.UserController.save(...)")
    @NotEmpty(message = "Java 方法名不能为空")
    private String javaMethod;

    /**
     * Java 方法的参数
     */
    @Schema(description = "Java 方法的参数")
    private String javaMethodArgs;

    /**
     * 开始时间
     */
    @Schema(description = "开始时间", required = true)
    @NotNull(message = "开始时间不能为空")
    private LocalDateTime startTime;

    /**
     * 执行时长，单位：毫秒
     */
    @Schema(description = "执行时长，单位：毫秒", required = true)
    @NotNull(message = "执行时长不能为空")
    private Integer duration;

    /**
     * 结果码
     */
    @Schema(description = "结果码", required = true)
    @NotNull(message = "结果码不能为空")
    private Integer resultCode;

    /**
     * 结果提示
     */
    @Schema(description = "结果提示")
    private String resultMsg;

    /**
     * 结果数据
     */
    @Schema(description = "结果数据")
    private String resultData;

}